﻿// JScript File


 function fnAdditems(bxFrom, bxTo, hiddenId) {
var from="ctl00_ContentPlaceHolder3_"+bxFrom;
var to="ctl00_ContentPlaceHolder3_"+bxTo;
var varFrombox = document.getElementById(from);
var varTobox = document.getElementById(to);

if ((varFrombox != null) && (varTobox != null)) {
if (varFrombox.length < 1) {
alert('There are no items in the source listbox');
return false;
} //if
if (varFrombox.options.selectedIndex == -1) // when no Item is selected the index will be -1
{
alert('Please select an Item to move');
return false;
} //if
while (varFrombox.options.selectedIndex >= 0) {

//var optn = document.createElement("OPTION");
var optn=new Option();
optn.text = varFrombox.options[varFrombox.options.selectedIndex].text;
optn.value = varFrombox.options[varFrombox.options.selectedIndex].value;
varTobox.options.add(optn);
varFrombox.remove(varFrombox.options.selectedIndex); //Remove the item from Source listbox

} //while

var temp = "";
//now add the items to the hidden field
for (var i = 0; i < varTobox.options.length; ++i) {

//add all of the values in the to box
//to a variable separating each selection id
//with a ,
temp += varTobox.options[i].value + ",";

} //for

//remove the last character of temp
//because it is an extra ,

var values = temp.substring(0, temp.length - 1);
var hih="ctl00_ContentPlaceHolder3_"+hiddenId;
var h = document.getElementById(hih);
h.value = values;

} //if
return false;
} //fnAdditems

//this function removes one item from the
//second listbox and removes it from
//the hidden field
function fnRemoveitems(bxFrom, bxTo, hiddenId) {

var from="ctl00_ContentPlaceHolder3_"+bxFrom;
var to="ctl00_ContentPlaceHolder3_"+bxTo;
var varFrombox = document.getElementById(from);
var varTobox = document.getElementById(to);


if ((varFrombox != null) && (varTobox != null)) {
if (varFrombox.length < 1) {
alert('There are no items in the source listbox');
return false;
} //if
if (varFrombox.options.selectedIndex == -1) // when no Item is selected the index will be -1
{
alert('Please select an Item to move');
return false;
} //if
while (varFrombox.options.selectedIndex >= 0) {

//var optn = document.createElement("OPTION");
var optn=new Option();
optn.text = varFrombox.options[varFrombox.options.selectedIndex].text;
optn.value = varFrombox.options[varFrombox.options.selectedIndex].value;
varTobox.options.add(optn);
varFrombox.remove(varFrombox.options.selectedIndex); //Remove the item from Source listbox

} //while
} //if

var temp = "";
//now remove the items to the hidden field
for (var i = 0; i < varFrombox.options.length; ++i) {

//add all of the values in the to box
//to a variable separating each selection id
//with a ,
temp += varFrombox.options[i].value + ",";

} //for

//remove the last character of temp
//because it is an extra ,

var values = temp.substring(0, temp.length - 1);
var hih="ctl00_ContentPlaceHolder3_"+hiddenId;
var h = document.getElementById(hih);
h.value = values;

return false;
} //fnRemoveitems

//this function moves all of the slections over and adds
//them to the hidden field
function moveSelections(bxFrom, bxTo, hiddenId) {

var from="ctl00_ContentPlaceHolder3_"+bxFrom;
var to="ctl00_ContentPlaceHolder3_"+bxTo;
var varFrombox = document.getElementById(from);
var varTobox = document.getElementById(to);

if (varFrombox.options.length < 1) {
alert('There are no items in that box');
return false;
} //if

for (var i = 0; i < varFrombox.options.length; ++i) {

var newOption = new Option(); // Create a new instance of listItem
newOption.text = varFrombox.options[i].text;
newOption.value = varFrombox.options[i].value;
varTobox.options[varTobox.options.length] = newOption; //Append the item in Target listbox

} //for

var i = 0;
var len = varFrombox.options.length;
while (varFrombox.options.length > 1) {

if (varFrombox.options.length = 1) {
varFrombox.remove(0); //Remove the item from Source listbox
} //if length = 1
else {
varFrombox.remove(1);
} //else

} //while

//add the value all to the listbox
var hih="ctl00_ContentPlaceHolder3_"+hiddenId;
document.getElementById(hih).value = "Right";

} //moveSelections

//this function removes all of the items
//from the second list box and removes them
//from the hidden field.

//-------Added by Rakatech for Task & Alerts------
function onlyNumbers(evt)
    {
            var e = event || evt; // for trans-browser compatibility
            var charCode = e.which || e.keyCode;
            if (charCode > 31 && (charCode < 48 || charCode > 57)&& (charCode!=46))
                    return false;         
            return true;
    }
    
function removeSelections(bxFrom, bxTo, hiddenId) {

var from="ctl00_ContentPlaceHolder3_"+bxFrom;
var to="ctl00_ContentPlaceHolder3_"+bxTo;
var varFrombox = document.getElementById(from);
var varTobox = document.getElementById(to);

if (varFrombox.options.length < 1) {
alert('There are no items in that box');
return false;
} //if

for (var i = 0; i < varFrombox.options.length; ++i) {

var newOption = new Option(); // Create a new instance of listItem
newOption.text = varFrombox.options[i].text;
newOption.value = varFrombox.options[i].value;
varTobox.options[varTobox.options.length] = newOption; //Append the item in Target listbox

} //for

var i = 0;
var len = varFrombox.options.length;

while (varFrombox.options.length >= 1) {

if (varFrombox.options.length = 1) {

varFrombox.remove(0); //Remove the item from Source listbox
} //if length = 1
else {
varFrombox.remove(1);
} //else

} //while

//add the value all to the listbox
var hih="ctl00_ContentPlaceHolder3_"+hiddenId;
document.getElementById(hih).value = "Left";

} //removeSelections 


         
        function validateDate()
        {
        
        var finish_date= document.getElementById("ctl00_ContentPlaceHolder3_p_task_config_finish_date").value ;
        var start_date= document.getElementById("ctl00_ContentPlaceHolder3_p_task_config_start_date").value ;
        alert(start_date);
        //var startDate = new Date(start_date.getFullYear(),start_date.getMonth(),start_date.getDate(),0,0,0);
        var startDate =date.getdate();
        alert("startDate");
        var finishDate = new Date.parseDate(finish_date);
        
            if(finishDate <=startDate)
            {
            alert("Finish Date should be greater than Start Date");
            return false;
            
            }
            else
                return true;
        
        }
        function Validation()
        {
              var status= new Boolean(true);
//       var str_date =new Array();
//        str_date[0]=document.getElementById("ctl00_ContentPlaceHolder3_p_task_config_start_date").value;
//         str_date[1]=document.getElementById("ctl00_ContentPlaceHolder3_p_task_config_finish_date").value;
//               if(str_date[0]!="" & str_date[1]!="")
//        {
//       var finishDate ;
//        var startDate;            
//          for(i=0;i<str_date.length ;i++)
//          {

//	        var arr_date = str_date[i].split('-');

//	        if (arr_date.length != 3) 
//	        {
//	        alert("Invalid date format: '" + str_date + "'.\nFormat accepted is mm-dd-yyyy.");
//	        status=false;
//	        }
//	        else
//	        {
//	            if (!arr_date[0])
//	            { 
//	            alert ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
//	            status=false;
//	            }
//        	
//	            if (!RE_NUM.exec(arr_date[0]))
//	            {
//	             alert ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
//	             status=false;
//	             }
//                if (!arr_date[1]) 
//                {
//                alert ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
//                status=false;
//                }
//	            if (!RE_NUM.exec(arr_date[1]))
//	            {
//	             alert ("Invalid month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
//	             status=false;
//	             }
//	            if (!arr_date[2]) 
//	            {
//	            alert ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
//	            status=false;
//	            }
//	            var year=arr_date[2].split(' ');
//	            if (!RE_NUM.exec(year[0])) 
//	            {
//	            alert ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");
//	            status=false;
//	            }
//	            if(year[0].length > 4)
//	            {
//	            alert ("Invalid year value: '" + arr_date[2] );
//	            status=false;
//	            
//	            }
//	            var time=year[1].split(':');
//	            if(time[0].length > 2||time[0].length <=0 )
//	            {
//	            alert ("Invalid Hour value: '" + time[0] );
//	            status=false;
//	            
//	            }
//	            if(time[1].length > 2||time[1].length <=0)
//	            {
//	            alert ("Invalid Minute value: '" + time[1] );
//	            status=false;
//	            
//	            }
//	            if(time[2].length > 2||time[2].length <=0)
//	            {
//	            alert ("Invalid Seconds value: '" + time[2] );
//	            status=false;
//	            
//	            }
//	            if (parseFloat(time[0]) > 23)
//	            { 
//	            alert ("Invalid Hour value: '" + arr_date[0] + "'.\nAllowed range is 00-23.");
//	            status=false;
//	            }
//	             if (parseFloat(time[1]) > 59)
//	            { 
//	            alert ("Invalid Minute value: '" + arr_date[0] + "'.\nAllowed range is 00-59.");
//	            status=false;
//	            }
//	             if (parseFloat(time[2]) > 59)
//	            { 
//	            alert ("Invalid Seconds value: '" + arr_date[0] + "'.\nAllowed range is 00-59.");
//	            status=false;
//	            }
//	            if (parseFloat(arr_date[0]) < 1 || parseFloat(arr_date[0]) > 12)
//	            { 
//	            alert ("Invalid month value: '" + arr_date[0] + "'.\nAllowed range is 01-12.");
//	            status=false;
//	            }
//	            var dt_numdays = new Date(year[0], arr_date[0], 0);
//	            var Maxday=dt_numdays.getDate();
//	             if (parseFloat(arr_date[1]) < 1 || parseFloat(arr_date[1]) > Maxday)
//	            { 
//	            alert ("Invalid day of Month value: '" + arr_date[1] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");
//	            status=false;
//	            }
//	            var month=arr_date[0]-1;
//         if(i==0)
//	            {
//	            startDate=new Date(year[0],month,arr_date[1],time[0],time[1],time[2]);
//	            }
//	            else(i==1)
//	            {
//	            finishDate=new Date(year[0],month,arr_date[1],time[0],time[1],time[2]);
//	            }
//	            
//        	}
//        	}
//        	}
//        	if(status==true)
//        	{
//        	if(startDate> finishDate)
//        	{
//        	alert('Please ensure that the Finish Date is greater than the Start Date');
//        	status=false;
//        	}
//        	}
        	if(document.getElementById("ctl00_ContentPlaceHolder3_object_ref").value=="0")
    {
    alert("Please Select a Related Object");
    status=false;
}
if (document.getElementById("ctl00_ContentPlaceHolder3_assign_to").value == "" && document.getElementById("ctl00_ContentPlaceHolder3_LstRight").options.length == 0) {
    alert("Please assign the task.");
    status = false;
}
	return status;


                }
    
                
                
        function DisableOp2()
        {
        var count= document.getElementById("ctl00_ContentPlaceHolder3_hd_chkCount").value;
    
        var x=0;
        if(document.getElementById("ctl00_ContentPlaceHolder3_p_task_config_alert_op1").checked ==true)
        {
       // document.getElementById("ctl00_ContentPlaceHolder3_p_task_config_alert_op2").disabled=true;
        
              for(i=0;i<count;i++)
              {
              document.getElementById("ctl00_ContentPlaceHolder3_chk_status_"+i).disabled = true;
             
              }
        
        }
        }
        function DisableOp1()
        {
        
       var count= document.getElementById("ctl00_ContentPlaceHolder3_hd_chkCount").value;
       if(document.getElementById("ctl00_ContentPlaceHolder3_p_task_config_alert_op2").checked ==true)
        {
            
              for(i=0;i<count;i++)
              {
              document.getElementById("ctl00_ContentPlaceHolder3_chk_status_"+i).disabled = false;
             
              }
        }
        
        }
        function ShowMulti()
        {
        
        if(document.getElementById("ctl00_ContentPlaceHolder3_assign_to").value =="")
        {
        document.getElementById("ctl00_ContentPlaceHolder3_p_taskassign_assign_to").value =0;
        }
//        if(document.getElementById("ctl00_ContentPlaceHolder3_p_taskassign_assign_to").value ==0)
//        {
            if(document.getElementById("ctl00_ContentPlaceHolder3_div_multiple").style.display=="none")
            {
             if(document.getElementById("ctl00_ContentPlaceHolder3_assign_to").value !="")
        {
        document.getElementById("ctl00_ContentPlaceHolder3_p_taskassign_multiple").value="0";
        document.getElementById("ctl00_ContentPlaceHolder3_LstLeft").options.length=0;
        document.getElementById("ctl00_ContentPlaceHolder3_LstRight").options.length=0;
        }
            document.getElementById("ctl00_ContentPlaceHolder3_div_multiple").style.display="block"
            document.getElementById("ctl00_ContentPlaceHolder3_AssignToLable").style.display="block"
             //document.getElementById("ctl00_ContentPlaceHolder3_assign_to").disabled=true;
           
            document.getElementById("ctl00_ContentPlaceHolder3_imgsearch1").style.visibility="hidden";
            }
            else if(document.getElementById("ctl00_ContentPlaceHolder3_div_multiple").style.display=="block")
            {
            if(document.getElementById("ctl00_ContentPlaceHolder3_p_taskassign_multiple").value =="0")
            {
            
            document.getElementById("ctl00_ContentPlaceHolder3_div_multiple").style.display="none"
            document.getElementById("ctl00_ContentPlaceHolder3_AssignToLable").style.display="none"
            document.getElementById("ctl00_ContentPlaceHolder3_imgsearch1").style.visibility="visible";
            document.getElementById("ctl00_ContentPlaceHolder3_assign_to").disabled=false;
            }
            else
            {
            document.getElementById("ctl00_ContentPlaceHolder3_div_multiple").style.display="none"
            document.getElementById("ctl00_ContentPlaceHolder3_AssignToLable").style.display="none"
            }
           
            }
            return true;
        
//        else
//        {
//            alert("User Already selected");
//            return false;
//         }
        }
        function hidemultiple()
        {
        
            if(document.getElementById("ctl00_ContentPlaceHolder3_div_multiple").style.display=="block")
            {
            document.getElementById("ctl00_ContentPlaceHolder3_div_multiple").style.display="none"
            document.getElementById("ctl00_ContentPlaceHolder3_AssignToLable").style.display="none"
            }
            
        
        
        }
        
        function CheckObj()
{
    if(document.getElementById("ctl00_ContentPlaceHolder3_object_ref").value=="0")
    {
    alert("Please Select a Related Object");
    }
}

